package com.taotao.job.executor.rpc;

import com.taotao.job.core.rpc.ExecutorIface;
import com.taotao.job.executor.rpc.ExecutorIfaceImple;
import com.taotao.job.rpc.sofabolt.SofaboltProviderServer;

/**
 *
 * @author fanbeibei
 * @date 2021/4/6 21:53
 */
public class TaotaoJobExecutorRpcServer {
    /**
     * port
     */
    private int port;

    /**
     * rpc server
     */
    private SofaboltProviderServer providerServer;

    public TaotaoJobExecutorRpcServer(int port) {
        this.port = port;
    }

    protected void initRpcServer() {
        providerServer = new SofaboltProviderServer(port);
        ExecutorIface executorIface = new ExecutorIfaceImple();
        providerServer.addProviderService(executorIface, ExecutorIface.class);
        providerServer.start();
    }


    public void start() {
        initRpcServer();
    }

    public void stop() {
        providerServer.stop();
    }
}
